package com.huawei;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.Map;

/**
 * Description: HJ63 DNA序列
 *
 * @author weiruibai.vendor
 * Date: 2022/8/23 14:52
 */
public class HJ63 {

    public static void main(String[] args) throws IOException {
        BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
        String dna = bf.readLine();
        int n = Integer.parseInt(bf.readLine());
        int size = dna.length();
        int maxGC = 0;
        int start = 0;
        int end = n;
        for (int i = 0; i < size - n; i++) {
            int tmpMaxGC = 0;
            for (int j = i; j < n + i; j++) {
                char ch = dna.charAt(j);
                if (ch == 'C' || ch == 'G') {
                    tmpMaxGC++;
                }
            }
            if (tmpMaxGC > maxGC) {
                maxGC = tmpMaxGC;
                start = i;
                end = i + n;
            }
        }
        System.out.println(dna.substring(start, end));
        bf.close();
    }
}

